import { createApp } from 'vue';
import App from './App.vue';

import ArcoVue from '@arco-design/web-vue';
import '@arco-design/web-vue/dist/arco.css';
import ArcoVueIcon from '@arco-design/web-vue/es/icon';
import '@arco-design/web-vue/dist/arco.css';
import 'nprogress/nprogress.css';
import '@/styles/index.less';

import 'virtual:windi-base.css';
import 'virtual:windi-components.css';
import 'virtual:windi-utilities.css';

import router, { setupRouter } from './router';
import { setupStore } from '@/store';
import { setupDirectives, setupGlobalMethods, setupCustomComponents } from '@/plugins';

async function bootstrap() {
  const app = createApp(App);

  app.use(ArcoVue).use(ArcoVueIcon);

  // 注册全局常用的 arco 组件
  // setupAntd(app);

  // 注册全局自定义组件,如：<svg-icon />
  setupCustomComponents(app);

  // 注册全局自定义指令，如：v-permission权限指令
  setupDirectives(app);

  // 注册全局方法，如：app.config.globalProperties.$message = message
  setupGlobalMethods(app);

  // 挂载状态管理
  setupStore(app);

  // 挂载路由
  setupRouter(app);

  // 路由准备就绪后挂载APP实例
  await router.isReady();

  app.mount('#app', true);
}

void bootstrap();
